function onPageReady() {
    ajax({
        url: "/api/match/myList",
        type: "post",
        dataType: "json",
        headers: {},
        data: {id: ""},
        success: function (result) {
            for (var i in result.data) {
                var item = new MatchBean(result.data[i]);
                if (item.policyTitle){
                    $(".main").render("#policy", item);
                }
            }
        }
    });

    var weixin = null, qq = null;
    try {
        plus.share.getServices(function (services) {
            for (var i in services) {
                switch (services[i].id) {
                    case 'weixin': {
                        weixin = services[i];
                        break;
                    }
                    case 'qq' : {
                        qq = services[i];
                        break;
                    }
                }
            }
        }, function (e) {
            console.log("获取分享服务列表失败：" + e.message);
        });
    } catch (e) {
    }
    var $collectionPolicy = null, policyId = '', policyTitle = '';
    $('.shareBar-bg').on('click', function () {
        $('.shareBar').hide();
    });
    collectionPolicy = function (id,_this) {
        $collectionPolicy = $(_this);
        if ($collectionPolicy.attr('data-is-collection')){
            ajax({
                url: "/api/home/markFavorite",
                type: "post",
                dataType: "json",
                headers: {
                    "content-type": "application/json"
                },
                data: JSON.stringify({
                    appUserId: getLocalItem("user") ? new AppUserBean(getLocalItem("user")).id : '',
                    status: 0,
                    subjectId: id,
                    type: "2"
                }),
                success: function (result) {
                    $collectionPolicy.attr('data-is-collection','');
                    toast('取消成功！');
                    $collectionPolicy.attr('style','background: url(\'../../../img/star-o.png\') center no-repeat;background-size: contain;');
                }
            });
        }else{
            ajax({
                url: "/api/home/markFavorite",
                type: "post",
                dataType: "json",
                headers: {
                    "content-type": "application/json"
                },
                data: JSON.stringify({
                    appUserId: getLocalItem("user") ? new AppUserBean(getLocalItem("user")).id : '',
                    status: 1,
                    subjectId: id,
                    type: "2"
                }),
                success: function (result) {
                    $collectionPolicy.attr('data-is-collection','true');
                    toast('收藏成功！');
                    $collectionPolicy.attr('style','background: url(\'../../../img/star-f.png\') center no-repeat;background-size: contain;');
                }
            });
        }
    };
    sharePolicy = function (id, title) {
        policyId = id;
        policyTitle = title;
        $('.shareBar').css('display', 'flex');
    };
    window.jumpShare = function (i) {
        var service = null, extra = {};
        switch (i) {
            case 1: {
                service = weixin;
                extra = {scene: "WXSceneTimeline"};
                break;
            }
            case 2: {
                service = qq;
                break;
            }
            default: {
                service = weixin;
                extra = {scene: "WXSceneSession"}
            }
        }
        ajax({
            url: "/api/home/getPolicyDetail/" + policyId,
            type: "get",
            dataType: "json",
            headers: {},
            success: function (result) {
                share(service, policyTitle, result.data, '', extra);
            }
        });
    }
}